<template>
  {{ dialogFormVisible }}
  <el-card style="max-width: 680px">
    <template #header>
      <div class="card-header">
        <span>Card name</span>
        <el-button :icon="Plus" type="primary" @click="dialogFormVisible = true"> 新建 </el-button>
      </div>
    </template>
    <el-table :data="allTodos" style="width: 100%" :row-class-name="tableRowClassName">
      <el-table-column prop="id" label="id" width="180" />
      <el-table-column prop="text" label="text" width="180" />
      <el-table-column prop="isFinished" label="isFinished" />
    </el-table>
    <template #footer>Footer content</template>
  </el-card>
</template>

<script setup>
import { useTodos } from '@/stores/todo.js'
import { storeToRefs } from 'pinia'
import { Plus } from '@element-plus/icons-vue'
const todos = useTodos()
const { allTodos, dialogFormVisible } = storeToRefs(todos)

const tableRowClassName = ({ row, rowIndex }) => {
  if (rowIndex % 2 === 1) {
    return 'warning-row'
  } else {
    return 'success-row'
  }
  return ''
}
</script>

<style>
.el-table .warning-row {
  --el-table-tr-bg-color: var(--el-color-warning-light-9);
}
.el-table .success-row {
  --el-table-tr-bg-color: var(--el-color-success-light-9);
}
.el-card {
  border-radius: 8px;
}
</style>
